<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/white/common/taglibs.jsp"%>
<%@include file="/white/common/common.jsp"%>

<html>
	<head>
		<script type="text/javascript">
        function saveInstanceContext(workflowInstanceId,contextId)
        {
        	var contextForm=document.getElementById("detailForm");
            contextForm.action="worklistAction-" + workflowInstanceId + "!saveInstanceContext.action?contextId=" + contextId;
            contextForm.submit();
            return true;
        }
        function saveNodeContext(workflowInstanceId,nodeContextId)
        {
        	var nodeContextForm=document.getElementById("detailForm");
            nodeContextForm.action="worklistAction-" + workflowInstanceId + "!saveNodeInstanceContext.action?nodeContextId=" + nodeContextId;
            nodeContextForm.submit();
            return true;
        }
        function deleteAttachment(workflowInstanceId,attachmentId)
        {
        	var attachmentForm=document.getElementById("detailForm");
            attachmentForm.action="worklistAction-" + workflowInstanceId + "!deleteAttachment.action?attachmentId=" + attachmentId;
            attachmentForm.submit();
            return true;
        }
        function toUploadAttachmentInstance(workflowInstanceId,attachmentId)
        {
        	var attachmentForm=document.getElementById("detailForm");
            attachmentForm.action="worklistAction-" + workflowInstanceId + "!toUploadAttachmentInstance.action?attachmentId=" + attachmentId;
            attachmentForm.submit();
            return true;
        }
        function toUploadNodeAttachmentInstance(workflowInstanceId,nodeAttachmentId)
        {
        	var attachmentForm=document.getElementById("detailForm");
            attachmentForm.action="worklistAction-" + workflowInstanceId + "!toUploadNodeAttachmentInstance.action?nodeAttachmentId=" + nodeAttachmentId;
            attachmentForm.submit();
            return true;
        }
        function deleteNodeAttachment(workflowInstanceId,nodeAttachmentId)
        {
        	var nodeAttachmentForm=document.getElementById("detailForm");
            nodeAttachmentForm.action="worklistAction-" + workflowInstanceId + "!deleteNodeAttachment.action?nodeAttachmentId=" +nodeAttachmentId;
            nodeAttachmentForm.submit();
            return true;
        }
        function searchNodeAttachmentHis(workflowInstanceId,nodeAttachmentId)
        {
        	var attachmentForm=document.getElementById("detailForm");
            attachmentForm.action="worklistAction-" + workflowInstanceId + "!searchNodeAttachmentHis.action?nodeAttachmentId=" + nodeAttachmentId;
            attachmentForm.submit();
            return true;
        }
    </script>
	</head>
	<body>

		<div id="div_title">
			<h3>
				完成&nbsp;<s:label name="workflow.name"/>&nbsp;<s:label name="workflowNode.name"/>&nbsp;工作
			</h3>
		</div>


		<!-- Data Form -->
		<%@include file="/white/common/message.jsp"%>
		<s:form method="post" action="worklistAction!showWorkDetail" id="detailForm" 
			theme="simple" enctype="multipart/form-data" >
			<s:token />
			<s:hidden name="workflowInstanceId" value="%{workflowInstance.workflowInstanceId}"/>
			
			
			<p>以下为模生成内容
			<br>
			<%=request.getAttribute("work_template")%>
			
			<br>
			
			
			<table cellpadding="0" cellspacing="0" class="t_form">

				<tr>
					<td width="15%">
						工作流实例ID:
					</td>
					<td>
						<s:property value="workflowInstance.workflowInstanceId" />
					</td>
				</tr>
				<tr>
					<td width="15%">
						所属工作流:
					</td>
					<td>
						<s:property value="workflow.name" />
					</td>
					<td width="15%">
						所在节点:
					</td>
					<td>
						<s:property value="workflowNode.name" />
					</td>
				</tr>
				<tr>
					<td width="15%">
						操作人:
					</td>
					<td>
						<c:if test="${workflowInstance.owner eq '-10000'}">
								默认操作员
						</c:if>
					</td>
					<td width="15%">
						状态:
					</td>
					<td>
						<s:property value="workflowInstance.status" />
					</td>
				</tr>

			</table>
			<div style="width: 70%">				
				<h4>
				流程参数列表:
			    </h4>
					
				<table cellpadding="0" cellspacing="0" class="t_list">
					<tr>
						<th>
							参数名称
						</th>
						<th>
							默认值
						</th>
						<th>
							参数类型
						</th>
						<th>
							当前值
						</th>
						<th>
							操作
						</th>
					</tr>
					<s:iterator value="contextList" status="sindex">
						<tr>
							<td>
								<s:property value="PARAM_NAME" />
							</td>
							<td>
								<s:property value="DEFAULT_VALUE" />
							</td>
							<td>
								<s:property value="PARAM_TYPE" />
							</td>
							<td>
								<s:property value="PARAM_VALUE" />
							</td>
							<td>
								<s:textfield name="paramValue"/>
								<a href="javascript:saveInstanceContext('${workflowInstance.workflowInstanceId}','${CONTEXT_ID}')" >
								<img alt="保存" src="wf/images/New.png" width="15"/></a>
							</td>
						</tr>
					</s:iterator>
				
				</table>
				<h4>
				流程附件列表:
			    </h4>
					
				<table cellpadding="0" cellspacing="0" class="t_list">
					<tr>
						<th>
							附件名称
						</th>
						<th>
							附件类型
						</th>
						<th>
							描述
						</th>
						<th>
							备注
						</th>
						<th>
							附件
						</th>
						<th>
							操作
						</th>
					</tr>
					<s:iterator value="attachmentList" status="sindex">
						<tr>
							<td>
								<s:property value="NAME" />
							</td>
							<td>
								<s:property value="TYPE" />
							</td>
							<td>
								<s:property value="DESCRIPTION" />
							</td>
							<td>
								<s:property value="NOTE" />
							</td>
							<td>
							<a href="<s:url value='download.action'>                  
                    				<s:param name='fileName'  
 									value='RESOURCE_ID'/>     
                 					</s:url>">
                 			<s:property value="FNAME" />
                 			</a>
							</td>
							<td>
								<a href="javascript:toUploadAttachmentInstance('${workflowInstance.workflowInstanceId}','${ATTACHMENT_ID}')" >
								<img alt="上传" src="wf/images/New.png" width="15"/></a>
								<a href="javascript:deleteAttachment('${workflowInstance.workflowInstanceId}','${ATTACHMENT_ID}')" >
								<img alt="删除" src="wf/images/Delete.png" width="15"/></a>
							</td>
						</tr>
					</s:iterator>
				
				</table>
				
				<h4>
				节点参数列表:
			    </h4>

				<table cellpadding="0" cellspacing="0" class="t_list">
					<tr>
						<th>
							参数名称
						</th>
						<th>
							默认值
						</th>
						<th>
							参数类型
						</th>
						<th>
							当前值
						</th>
						<th>
							操作
						</th>
					</tr>
					<s:iterator value="nodeContextList" status="sindex">
						<tr>
							<td>
								<s:property value="PARAM_NAME" />
							</td>
							<td>
								<s:property value="DEFAULT_VALUE" />
							</td>
							<td>
								<s:property value="PARAM_TYPE" />
							</td>
							<td>
								<s:property value="PARAM_VALUE" />
							</td>
							<td>
								<s:textfield name="nodeParamValue"/>
								<a href="javascript:saveNodeContext('${workflowInstance.workflowInstanceId}','${NODE_CONTEXT_ID}')" >
								<img alt="保存" src="wf/images/New.png" width="15"/></a>
							</td>
						</tr>
					</s:iterator>
				</table>
				<h4>
				节点附件列表:
			    </h4>
					
				<table cellpadding="0" cellspacing="0" class="t_list">
					<tr>
						<th>
							附件名称
						</th>
						<th>
							附件类型
						</th>
						<th>
							描述
						</th>
						<th>
							备注
						</th>
						<th>
							附件
						</th>
						<th>
							操作
						</th>
					</tr>
					<s:iterator value="nodeAttachmentList" status="sindex">
						<tr>
							<td>
								<s:property value="NAME" />
							</td>
							<td>
								<s:property value="TYPE" />
							</td>
							<td>
								<s:property value="DESCRIPTION" />
							</td>
							<td>
								<s:property value="NOTE" />
							</td>
							<td>
							<a href="<s:url value='download.action'>                  
                    				<s:param name='fileName'  
 									value='RESOURCE_ID'/>     
                 					</s:url>">
                 			<s:property value="FNAME" />
                 			</a>
							</td>
							<td>
								<a href="javascript:toUploadNodeAttachmentInstance('${workflowInstance.workflowInstanceId}','${NODE_ATTACHMENT_ID}')" >
								<img alt="上传" src="wf/images/New.png" width="15"/></a>
								<a href="javascript:deleteNodeAttachment('${workflowInstance.workflowInstanceId}','${NODE_ATTACHMENT_ID}')" >
								<img alt="删除" src="wf/images/Delete.png" width="15"/></a>
								<a href="javascript:searchNodeAttachmentHis('${workflowInstance.workflowInstanceId}','${NODE_ATTACHMENT_ID}')" >
								<img alt="历史" src="wf/images/Delete.png" width="15"/></a>
							</td>
						</tr>
					</s:iterator>
				
				</table>				
			</div>
			<div style="width: 50%">				
				<h4>
				流转记录:
			    </h4>
					
				<table cellpadding="0" cellspacing="0" class="t_list">
					<tr>
						<th>
							节点名称
						</th>
						<th>
							处理人
						</th>

					</tr>
					<s:iterator value="workflowNodeInstanceMapList" status="sindex">
						<tr>
							<td>
								<s:property value="WORKFLOW_NODE_NAME" />
							</td>
							<td>
								<c:if test="${WORKER eq '-10000'}">
									默认操作员
								</c:if>
							</td>
						</tr>
					</s:iterator>
				</table>				
			</div>
			
			<div id="div_button">
			    操作选择:
			    <s:select list="nodeList" listKey="WORKFLOW_PATH_ID"
									listValue="PATH_DISPLAY_NAME" headerKey="" headerValue="=== 请选择 ==="
									name="nextWorkflowNodeId" id="nextWorkflowNodeId">
				</s:select>
			    
				<c:if test="${workflowInstance.status ne 'end'}">
					<s:submit key="提交"
						action="worklistAction-%{workflowInstance.workflowInstanceId}!goNext"
						onclick=""
						cssClass="input_button" />
				</c:if>
				<br /><br />
				<s:submit key="返回"
					onclick="form.action='worklistAction!showWorkList.action';return true;"
					cssClass="input_button" />
			</div>

			<s:hidden name="searchString" />

		</s:form>

		<!--Data Form End -->

	</body>

</html>